﻿using System;
using System.Net.Sockets;
using System.Text;
using HBase.cache;

namespace HBase
{
    public class HeadlessBaseResult : BaseResultAbs
    {
    
        public String data { get; set; }

        public static HeadlessBaseResult Error(string message = "操作失败！" )
        {
            
            HeadlessBaseResult r = new HeadlessBaseResult();
            r.data = "HTTP/1.0 555 OK\n"+message; 
            return r;
        }
        public static HeadlessBaseResult ok(string message = "操作成功！")
        {
            HeadlessBaseResult r = new HeadlessBaseResult();
            r.data = "HTTP/1.0 200 OK\r\n\r\n" + message +"\r\n";
            return r;
        }

        public void Write(NetworkStream networkStream)
        {
            
            byte[] b = System.Text.Encoding.UTF8.GetBytes(data.ToString()); 
            networkStream.Write(b, 0, b.Length);
      
            networkStream.Flush();

        }
        }
}
